--测试100万次的时间消耗

print(package.cpath)

--package.path = package.path..";./protobuf/?.so"
package.cpath = package.cpath..";./protobuf/?.so"
require "test2_pb"


--[[

local begin = os.clock()

local f = io.open("test3.bin", "rb")
local t = f:read("*all")

for i = 1, 100000 do
    local per = test2_pb.Person()
    per:MergeFromString(t)
    --print(per)
end

local e = os.clock()


print("Cost", e-begin)
]]

local begin = os.clock()

local f = io.open("test3.bin", "rb")
local t = f:read("*all")
local per = test2_pb.Person()
per:MergeFromString(t)

for i = 1, 100000 do
  	local s = per:SerializeToString()
    --print(s)
end

local e = os.clock()


print("Cost", e-begin)